using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms;

namespace FluentBinding.WinForms.Controls
{
    public class ControlBinding<E> : IControlBinding<E>
    {
        #region Fields

        protected readonly BindingProxy<E> _bindingProxy;        

        #endregion

        #region Constructors

        public ControlBinding(BindingProxy<E> bindingProxy)
        {
            _bindingProxy = bindingProxy;            
        }

        #endregion

        #region IControlBinding<E> Members

        public IPropertyBinding<E, P> Property<P>(string name)
        {
            _bindingProxy.BindTo(name);

            return new PropertyBinding<E, P>(_bindingProxy);
        }

        #endregion

        #region Public properties

        public IPropertyBinding<E, string> Text
        {
            get { return Property<string>("Text"); }
        }

        public IPropertyBinding<E, bool> Visible
        {
            get { return Property<bool>("Visible"); }
        }

        public IPropertyBinding<E, bool> Enabled
        {
            get { return Property<bool>("Enabled"); }
        }

        #endregion
    }
}